//
//  MZRecommendCollectionViewCell.m
//  OurTourism
//
//  Created by 孟镇 on 15/11/25.
//  Copyright © 2015年 Devil_Coming. All rights reserved.
//

#import "MZRecommendCollectionViewCell.h"
#import "Header.h"

@interface MZRecommendCollectionViewCell ()

@property(nonatomic, strong) UIImageView *imgView;
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIImageView *jianBianView;

@end

@implementation MZRecommendCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imgView = [[UIImageView alloc]init];
        self.imgView.layer.masksToBounds = YES;
        self.imgView.layer.cornerRadius = 10;
        [self.contentView addSubview:self.imgView];
        
        self.jianBianView = [[UIImageView alloc] init];
        [self.imgView addSubview:self.jianBianView];
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.textColor = [UIColor colorWithRed:0.98 green:0.94 blue:0.87 alpha:1];
        self.titleLabel.shadowColor = [UIColor grayColor];
        self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
        [self.contentView addSubview:self.titleLabel];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.imgView.frame = self.contentView.frame;
    self.jianBianView.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height);
    self.jianBianView.image = [UIImage imageNamed:@"jiabian"];
    self.titleLabel.frame = CGRectMake(10, layoutAttributes.size.height - 30, layoutAttributes.size.width - 20, 20);
}

- (void)setTemp:(MZRecommendModel *)temp
{
    _temp = temp;
    self.titleLabel.text = temp.name;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:temp.cover] placeholderImage:[UIImage imageNamed:@"collectionItem"]];
}
@end
